import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  {
    path: '',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {title: '首页', icon: 'home',affix: true},
    }]
  }
]

export const asyncRouterMap = [

  {
    path: '/data_dictionary',
    component: Layout,
    redirect: '/data_dictionary/project_management',
    name: 'data_dictionary',
    meta: {title: '数据字典', icon: 'data_dictionary'},
    children: [
      {
        path: 'project_management',
        name: 'project_management',
        component: () => import('@/views/data_dictionary/project_management'),
        meta: {title: '项目管理', icon: 'project_management'}
      },
      {
        path: 'page_configuration',
        name: 'page_configuration',
        component: () => import('@/views/data_dictionary/page_configuration'),
        meta: {title: '页面配置', icon: 'page_configuration'}
      },
      {
        path: 'data_update',
        name: 'data_update',
        component: () => import('@/views/data_dictionary/data_update'),
        meta: {title: '数据更新', icon: 'data_update'},
      },
    ]
  },
  {
    path: '/authority_control',
    component: Layout,
    redirect: '/authority_control/project_administrator_configuration',
    name: 'authority_control',
    alwaysShow: true,
    meta: {title: '权限控制',icon:'authority_control'},
    children: [
      {
        path: 'project_administrator_configuration',
        name: 'project_administrator_configuration',
        component: () => import('@/views/authority_control/project_administrator_configuration'),
        meta: {title: '项目管理员配置',icon:'project_administrator_configuration'}
      }
    ]
  },

  {
    path: '/permission',
    component: Layout,
    redirect: '/permission/menu',
    name: 'permission',
    meta: {title: '权限',icon:'permission'},
    children: [
      {
        path: 'permission/menu',
        name: 'menu',
        component: () => import('@/views/permission/menu'),
        meta: {title: '菜单',icon:'menu'}
      },
      {
        path: 'permission/role',
        name: 'role',
        component: () => import('@/views/permission/role'),
        meta: {title: '角色',icon:'role'}
      },
      {
        path: 'permission/user_table',
        name: 'user_table',
        component: () => import('@/views/permission/user_table'),
        meta: {title: '用户列表',icon:'user_table'}
      },
      {
        path: 'permission/user_agent',
        name: 'user_agent',
        component: () => import('@/views/permission/user_agent'),
        meta: {title: '用户代理',icon:'user_agent'}
      },
      {
        path: 'permission/system_list',
        name: 'system_list',
        component: () => import('@/views/permission/system_list'),
        meta: {title: '系统列表',icon:'system_list'}
      },
      {
        path: 'permission/button_configuration',
        name: 'button_configuration',
        component: () => import('@/views/permission/button_configuration'),
        meta: {title: '按钮配置',icon:'button_configuration'}
      },
      {
        path: 'permission/user_role_association',
        name: 'user_role_association',
        component: () => import('@/views/permission/user_role_association'),
        meta: {title: '用户角色关联',icon:'user_role_association'}
      },
      {
        path: 'permission/user_permission',
        name: 'user_permission',
        component: () => import('@/views/permission/user_permission'),
        meta: {title: '用户权限',icon:'user_permission'}
      },
    ]
  },

  {
    path: '/workflow',
    component: Layout,
    redirect: '/workflow/workflow_project_configuration',
    name: 'workflow',
    meta: {title: '工作流',icon:'workflow'},
    alwaysShow: true,
    children: [
      {
        path: 'workflow/workflow_project_configuration',
        name: 'workflow_project_configuration',
        component: () => import('@/views/workflow/workflow_project_configuration'),
        meta: {title: '工作流项目配置',icon:'workflow_project_configuration'}
      },
    ]
  },
  
  {path: '*', redirect: '/404', hidden: true}

]

export default new Router({
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

